package com.wisely.websocket;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;


/**
 * 配置Websocket
 */
@Configuration
@EnableWebSocketMessageBroker//开启WebSocket支持
public class WebsocketConfigure extends AbstractWebSocketMessageBrokerConfigurer{

    //重写这两个方法进行WebSocket配置
    @Override
    public void registerStompEndpoints(StompEndpointRegistry registry) {
        registry.addEndpoint("/endpointWisely").withSockJS();
        registry.addEndpoint("/endpointChat").withSockJS();//注册一个endpoint名字是endpointChat
    }

    @Override
    public void configureMessageBroker(MessageBrokerRegistry registry) {
        //registry.enableSimpleBroker("/topic");
        registry.enableSimpleBroker("/queue","/topic");//增加一个消息代理
    }
}
